//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

#include "tachometerwidget.h"
#include "ui_tachometerwidget.h"


TachometerWidget::TachometerWidget(quint16 baseID, CanGateway * canGateway, QWidget *parent) :
    QFrame(parent),
    m_ui(new Ui::TachometerWidget)
{
    m_ui->setupUi(this);
    setAttribute(Qt::WA_DeleteOnClose);

    tachometer = new Tachometer(baseID, canGateway, this);
    tachometer->setSpeedLabel(m_ui->speedLabel);
    m_ui->baseIdLabel->setText(tr("%1").arg(baseID));
}

TachometerWidget::~TachometerWidget()
{
    delete m_ui;
}

void TachometerWidget::on_sendButton_clicked()
{
    tachometer->setSpeed(m_ui->speedSpinBox->value());
}

void TachometerWidget::on_closeButton_clicked()
{
    close();
}

void TachometerWidget::setLogTextEdit(QTextEdit *logTextEdit)
{
    this->logTextEdit = logTextEdit;
}

quint16 TachometerWidget::getBaseID()
{
    return tachometer->getBaseID();
}
